import statService from '@/api/stat/stat'

let data = new class {
  // 各业务系统任务数据大小统计

  constructor() {
    this.xAxisData = [];
    this.dataFirs=[]
    this.dataSec=[]
    // this.createData()
  }
  setConfig(param){
    // 为整个类设置个性化参数
    return this
  }

  async getData() {
    let {success,data}=await statService.queryBusinessSystem()
    // statService.queryStatusCount().then(res => {
    //   if (res.success) {
    //     res.data.forEach(item => {
    //       this.formatCount(item)
    //     })
    //     this.reload = true
    //   }
    // }).catch((err) => console.log(err))
    return {success,data}
  }
  formatCount(item) {
    let count = parseInt(item.count)
    let status = parseInt(item.status)
    if (status == 5 || status == 6) {
      return
    }
    let str = ''
    // eslint-disable-next-line no-unused-vars
    let img = ''
    // eslint-disable-next-line no-unused-vars
    let color = ''
    switch (status) {
      case 0:
        str = '待打包'
        img = '/admin.jpg'
        color = color1[0]
        break // 待打包
      case 1:
        str = '已打包'
        img = 'admin.jpg'
        color = color1[1]
        break // 已打包
      case 2:
        str = '已分发'
        img = '/public/admin.jpg'
        color = color1[2]
        break // 已分发
      case 3:
        str = '执行成功'
        img = './public/admin.jpg'
        color = color2[0]
        break // 执行成功
      case 4:
        str = '执行失败'
        img = '/models/admin.jpg'
        color = color2[1]
        break // 执行失败
      // case 5:
      //   str = "待审批"
      //   break; //待审批
      // case 6:
      //   str = "已驳回"
      //   break; //已驳回
    }
    //  this.data.push({value:count, symbol:'localhost:8080/'+img, symbolSize: [30, 30]});
    this.data.push({
      value: 3
    })
    this.des.push(str)
  }
  async createData(){
    this.xAxisData=[]
    this.dataFirs=[]
    this.dataSec=[]
    let {success,data} = await this.getData();
    if(success){
      data.forEach(item => {
        this.xAxisData.push(item.systemName)
        this.dataFirs.push(item.size)
        this.dataSec.push(item.size)
        // this.formatCount(item)
      })
    }else{
      throw new Error('出错了')
    }
    return {
      "xAxisData":this.xAxisData,
      "dataFirs":this.dataFirs,
      "dataSec":this.dataSec
    };
  }
}

export {
data
}
